IF EXISTS (SELECT * FROM SYSOBJECTS WHERE name = 'ProfessorSubject' AND xtype = 'U')
BEGIN
	DROP TABLE ProfessorSubject
END
ELSE
	BEGIN
		CREATE TABLE  ProfessorSubject
		(
			ProfessorId		int not null, 
			SubjectId		int not null
		)
	END
GO

IF NOT EXISTS (SELECT * FROM SYSOBJECTS WHERE name = 'pk_ProfessorSubejctId' AND xtype = 'PK')
BEGIN
	ALTER TABLE ProfessorSubject
	ADD CONSTRAINT pk_Professorcd_Subject PRIMARY KEY ([ProfessorId],[SubjectId])
	
END
GO

IF NOT EXISTS(SELECT * FROM SYSOBJECTS WHERE name = 'fk_cd_Professor' AND xtype = 'F')
BEGIN
	ALTER TABLE ProfessorSubject
	ADD CONSTRAINT	fk_cd_Professor FOREIGN KEY ([ProfessorId])
	REFERENCES Professors
END
GO

IF NOT EXISTS(SELECT * FROM SYSOBJECTS WHERE name = 'fk_cd_Subjects' AND xtype = 'F')
BEGIN
	ALTER TABLE ProfessorSubject
	ADD CONSTRAINT	fk_cd_Subject FOREIGN KEY ([SubjectId])
	REFERENCES Subjects
END
GO